package com.kerwin.async;


import com.kerwin.permmgt.entity.Permissions;
import com.kerwin.permmgt.mapper.PermMapper;
import com.kerwin.utils.SpringContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*生产者消费者模式*/
/*这里负责生产任务线程*/
public class AsyncFactory {

    private static Logger log = LoggerFactory.getLogger(AsyncFactory.class);

    /*需要Permissions的Mapper*/

    public static Runnable addPermToMySql(Permissions permissions){

        /*从容器里面拿泛型的对象*/
        /*BaseMapper<Permissions> baseMapper = bean.getBaseMapper(BaseMapper<Permissions>.class);*/

       /* PermService bean = SpringContextUtil.getBean(PermService.class);
        BaseMapper<Permissions> permMapper = bean.getBaseMapper();*/

        PermMapper permMapper = SpringContextUtil.getBean(PermMapper.class);
        log.info("异步线程：添加权限到数据库");
        return new Runnable() {
            @Override
            public void run() {
                int insert = permMapper.insert(permissions);
            }
        };
    }




}
